#include <unistd.h>
#include <errno.h>

/* Persistent state for the robust I/O (Rio) package */
/* $begin rio_t */
#define RIO_BUFSIZE 8192
typedef struct {
    int rio_fd;                /* descriptor associated with internal buf */
    int rio_cnt;               /* number of unread bytes in internal buf */
    char *rio_bufptr;          /* next unread byte in internal buf */
    char rio_buf[RIO_BUFSIZE]; /* internal buffer */
} rio_t;
/* $end rio_t */

/* Robust I/O package */
int rio_init(rio_t *rp, int fd); 
ssize_t	rio_readn(rio_t *rp, void *usrbuf, size_t n);
ssize_t	rio_readline(rio_t *rp, void *usrbuf, size_t maxlen);
ssize_t rio_writen(int fd, void *usrbuf, size_t n);
